var Searcher = {
	searcher: {
		current: 1, //默认值
		limit: 90,
		count: 0,
		filerId: '',
		text: '',
		leis: '',
		teams: [],
		textType: '智能', //智能 商标名 注册号 申请人
		types: [], //'含中文', '含英文', '含数字', '纯图形'
		ageStart: '',
		ageEnd: '',
		//priceStart:0,
		//priceEnd:8000,
		exportPage: '', //批量导出
		fixedPrice: '',
		percentPrice: '',
		exact: false,
		sqType: '', //申请人类型
		blackSqNamer: 0, //默认不保留暂不转让的商标!!
		noNames: [] //不含的列
	},
	lastSearch: '',
	//选中的id
	ids: [],
	flag: {
		finished: false,
		isLoading: false,
		page: '' //table,my_brander,saver or ''
	},
	items: [],
	total: '',
	indexOfItems: function(id) {
		for (let i = 0; i < this.items.length; i++) {
			if (this.items[i].id == id) {
				return i;
			}
		}
		return -1;
	},
	getItemById: function(id) {
		let index = this.indexOfItems(id);
		return this.items[index];
	},
	removeByIds: function(ids) {
		ids = bbk.clone(ids); //重要,循环过程中,会影响length值
		for (let i = 0; i < ids.length; i++) {
			this.ids.remove(ids[i]);
		}
	},
	remove: function(branders) {
		for (let i = 0; i < branders.length; i++) {
			this.ids.remove(branders[i].id);
		}
	},
	setText: function() {
		let text = bbk.getVal('search-input');
		if (/[^\u4e00-\u9fa5\w\s（）()]/.test(text)) {
			//去掉多余符号
			this.searcher.text = text.replace(/[^\u4e00-\u9fa5\w\s（）()·]/g, ' ');
			Msger.info('已去掉多余符号');
			$('#search-input').val(this.searcher.text);
		} else {
			this.searcher.text = text;
		}
		if (this.searcher.text.length > Cons.SEARCHER.TEXT_MAX_SIZE) {
			let tail = this.searcher.text.substring(Cons.SEARCHER.TEXT_MAX_SIZE, this.searcher.text.length);
			this.searcher.text = this.searcher.text.substring(0, Cons.SEARCHER.TEXT_MAX_SIZE);
			Msger.info('关键词过长,已忽略「' + tail + '」');
		}
	},
	clickSearchBtn: function() {
		this.setText();
		this.searcher.current = 1;
		this.doSearch();
	},
	clickTextTypeBtn: function(obj) {
		$('.search-nav-choosed').removeClass('search-nav-choosed');
		obj.className += ' search-nav-choosed';
		this.searcher.textType = obj.innerHTML;
	},
	searchVue: {
		el: '#app',
		data: {
			items: [],
			saverIds: [],
			theme: {
				baseColor: Cons.baseColor
			}
		},
		methods: {
			isEmpty: function(str) {
				return bbk.isEmpty(str)
			},
			getPicUrl: function(item) {
				//return Imger.getUrl(item, Cons.IMAGE_TYPE.COLOR_250);
				return item.thumb_image;
			},
			getLei: function(item) {
				return item.lei + '类 (' + Cons.leis[item.lei - 1] + ')';
			},
			getUrl: function(item) {
				let from = 'on';
				switch (Searcher.searcher.page) {
					case Cons.PAGE.MY_BRANDER_ERROR:
						from = 'off';
						break;
					case Cons.PAGE.MY_BRANDER_OFF:
						from = 'off';
						break;
				}
				return '/mobile/brander_user?brander_id=' + item.id + '&from=' + from;
			},
			isGreenBorder: function(item) {
				if (ChooseItemer.isChoosed(item.id)) {
					return 'border-color: rgb(50, 205, 50);';
				}
				return '';
			},
			isGreenBackground: function(item) {
				if (ChooseItemer.isChoosed(item.id)) {
					return 'background:green;color:#fff';
				}
				return '';
			},
			isShowIcon: function() {
				try {
					if (!layui.device().mobile) {
						return 'display:none;';
					}
				} catch (e) {
					console.error(e);
				}
				return 'display:inline-block;';
			},
			hasBrother: function(item) {
				return !bbk.isEmpty(item.brother)
			},
			getBrotherSize: function(item) {
				if (!bbk.isEmpty(item.brother)) {
					return item.brother.length / 3;
				}
			},

			getBrotherText: function(item) {
				if (!bbk.isEmpty(item.brother)) {
					let arr = item.brother.split(";");
					let text = '';
					for (let i = 0; i < arr.length - 1; i++) {
						text += arr[i] + '类';
						if (i < arr.length - 2) {
							text += '，';
						}

					}
					return text;
				}
			},
			getBrandTip: function(item) {
				if (!bbk.isEmpty(item.brother)) {
					return '<span title="' + this.getBrotherText(item) +
						'" class="item-brand-tip">同名' + item
							.brother.length / 3 + '类</span>';
				}
				if (item.blackSqNamer == 1) {
					return '<span class="item-brand-tip" style="background:#990000;border-color:#990000">暂缓转让</span>';
				} else if (item.blackSqNamer == 2) {
					return '<span class="item-brand-tip" style="background:#990000;border-color:#990000">仅授权</span>';
				}
			},
			getPrice: function(item) {
				
				if (item.errorCode == 3 || item.errorCode == 4) {
					return '已卖出';
				}
				if (item.blackSqNamer == 1) {
					return '暂不转让';
				}
				if (item.blackSqNamer == 1) {
					return '暂缓转让';
				} else if (item.blackSqNamer == 2) {
					return '仅授权';
				}
				if (item.price == 0) {
					return '面议';
				}
				return '¥' + item.price;
			},
			showDetail: function(item) {
				let that = this;
				let saveStyle = 'style="color:#ff5500"';
				let saveText = '';
				if (this.saverIds.indexOf(item.id) == -1) {
					saveStyle = '';
					//saveText = '<span id="show-detail-save-text">收藏</span>';
				}
				let saveBtn = '';
				layer.open({
					title: '<i class="iconfont icon-trademark">' + item.name + '-' + item.lei +
						'类-商标详情' + '</i>',
					type: 2,
					area: ['98%', '80%'],
					resize: true,
					content: '/mobile/brander_user?brander_id=' + item.id + '&from=' +
						BranderUtil.getFrom(),
					btn: ['关闭'],
					shadeClose: true,
					btn2: function() {
						if (that.saverIds.indexOf(item.id) == -1) {
							$('.show-detail-save-icon').css('color', '#ff5500');
							//$('#show-detail-save-text').html('取消收藏')
						} else {
							$('.show-detail-save-icon').css('color', '');
							//$('#show-detail-save-text').html('收藏')
						}
						that.save(item);
						return false;
					}
				})
			},
			getSaverBtnStyle: function(item) {
				if (this.saverIds.indexOf(item.id) > -1) {
					return 'color:#ff5500';
				} else {
					return '';
				}
			},
			isShowSaveStar: function() {
				if (Searcher.searcher.page == Cons.PAGE.SAVER) {
					return true;
				}
			},
			//收藏
			save: function(item) {
				if (this.saverIds.indexOf(item.id) > -1) {
					let ajax = {
						url: '/buyer-saver/remove',
						data: {
							ids: [item.id]
						},
						success: function() {
							Searcher.searchVue.data.saverIds.remove(item.id);
							localStorage.INDEX_SAVER_BRANDER = JSON.stringify(Searcher.searchVue.data
								.saverIds);
						},
						error: function(res) {
							if (res.code == Cons.ERROR_CODE.NOT_LOGIN) {
								Login.login(false, function() {
									bbk.ajax(ajax);
								})
								return false;
							}
						}
					}

					bbk.ajax(ajax);
				} else {
					let ajax = {
						url: '/buyer-saver/save',
						data: {
							ids: [item.id]
						},
						success: function() {
							Searcher.searchVue.data.saverIds.push(item.id)
							localStorage.INDEX_SAVER_BRANDER = JSON.stringify(Searcher.searchVue.data
								.saverIds);
						},
						error: function(res) {
							if (res.code == Cons.ERROR_CODE.NOT_LOGIN) {
								Login.login(false, function() {
									bbk.ajax(ajax);
								})
								return false;
							}
						}
					}
					bbk.ajax(ajax);
				}

			}

		}
	},
	initVue: function() {
		let saverIds = localStorage.INDEX_SAVER_BRANDER ? JSON.parse(localStorage.INDEX_SAVER_BRANDER) : [];
		this.searchVue.data.saverIds = saverIds;
		this.searchVue.data.items = this.items;
		new Vue(this.searchVue);
	},
	keyUp: function(e) {
		let keyCode;
		if (window.event) {
			keyCode = event.keyCode;
		} else if (e.which) {
			keyCode = e.which;
		}
		if (keyCode == 13) {
			Searcher.clickSearchBtn();
		}
		//叉号 显示与关闭
		if (bbk.isEmpty($('#search-input').val())) {
			$('.search-input-close-icon').css('color', '#fff');
		} else {
			$('.search-input-close-icon').css('color', '#222');
		}
	},
	initCount: function() {
		setTimeout(function() {
			let ajax = {
				url: '/user/get-user-for-num',
				success: function(res) {
					console.info(res);
					$('#my-on-count').html('(' + res.data.onNum + ')');
					$('#my-off-count').html('(' + res.data.offNum + ')');
					$('#my-sold-count').html('(' + res.data.soldNum + ')');
					$('#black-sq-name-count').html('(' + res.data.blackSqNamerNum + ')');
					$('#my-error-count').html('(' + res.data.errorNum + ')');
				},
				error: function(res) {
					if (res.code = Cons.ERROR_CODE.NOT_LOGIN) {
						//避免弹出多个登陆窗口
						return false;
					}
				}
			}
			bbk.ajax(ajax);
		}, 500)
	},
	initTotal: function() {
		let ajax = {
			url: '/get-total',
			success: function(res) {
				let jgg = bbk.isBuyer() ? '' : '做九宫格，';
				$('#page-neck-text').html(
					'找标，' + jgg +
					'来这里就对了! → <span id="icon-id-box-1"></span><span style="font-size:15px">biaobiaoku.com</span><span id="icon-id-box-2"></span> 已收录' +
					res.data.total + '个商标');
				bbk.initIconId();
			}
		}
		setTimeout(function() {
			if (Searcher.searcher.page == 'index') {
				bbk.ajax(ajax);
			}
		}, 1000)
	},
	// setLogoColor: function(color) {
	// 	$('.logo-color-body').css('background', color);
	// 	$('.logo-box').css('background', color);
	// 	$('.logo-inner-middle-circle').css('background', color);
	// 	$('.logo-eye-box').css('background', color);
	// },
	//不同的页面
	initUrlVal: function() {
		Searcher.searcher.page = bbk.getUrlVal('page');
		Searcher.searcher.host = location.host;
		Searcher.searcher.weixin = layui.device().weixin ? true : false;
		let chooseOn = '';
		let chooseOff = '';
		let chooseSold = '';
		let chooseError = '';
		switch (Searcher.searcher.page) {
			//我的收藏
			case 'saver':
				//第一次打开收藏，初始化本地收藏的数据
				let ajax = {
					url: '/buyer-saver/init-my-saver',
					success: function(res) {
						localStorage.INDEX_SAVER_BRANDER = JSON.stringify(res.data);
						Searcher.searchVue.data.saverIds.removeAll();
						for (let i = 0; i < res.data.length; i++) {
							Searcher.searchVue.data.saverIds.push(res.data[i])
						}
					}
				}
				bbk.ajax(ajax);
				break;
			case Cons.PAGE.SIMPLE_LIST:
				$('.header-box').css('display', 'none');
				let searcher = Searcher.searcher;
				searcher.md = bbk.getUrlVal('md');
				break;
			//已上架
			case Cons.PAGE.TEAMER_SOLD:
				$('#my-brander-batch-box').html(
					'<div onclick="DataPartner.exportAll()" class="layui-btn layui-btn-sm layui-btn-primary"><i class="layui-icon  layui-icon-export"></i>全部导出（无图样）</div>'
				);
				$('#page-neck-text').html(
					'当前页面是<span style="color:blue">「团队已卖出商标」</span> → <a href="/?page=teamer_on">点我查看团队已上架的商标</a>'
				);
				break;
			default:
				Searcher.searcher.page = Cons.PAGE.INDEX;
		}

	},
	initParam: function() {
		if (bbk.getUrlVal('from') != 'buyer_site_url') {
			return;
		}
		if (!bbk.isEmpty(localStorage.SEARCHER)) {
			try {
				Searcher.searcher = JSON.parse(JSON.parse(localStorage.SEARCHER));
				let searcher = Searcher.searcher;
				searcher.textType = '智能';
				searcher.searchMode = 0;
				searcher.orderBy = undefined;
				searcher.distinct = false;
				searcher.exact = false;
				searcher.priceEnd = searcher.priceEnd > 1000000 ? 1000000 : searcher.priceEnd;
				searcher.weixin = layui.device().weixin ? true : false;
			} catch (e) {
				console.error(e);
				localStorage.SEARCHER = '';
			}

		}
	},
	setBlackSqNamers:function(names){
		console.info(names)
		let codes=[];
		for(let i=0;i<names.length;i++){
			switch(names[i]){
				case '正常':
				codes.add(0);
				break;
				case '暂缓转让':
				codes.add(1);
				break;
				case '仅授权':
				codes.add(2);
				break;
			}
		}
		Searcher.searcher.blackSqNamers = codes;
		names=bbk.isEmpty(names)?['正常']:names;
		ParamerNav.add('申请人:'+names);
		console.info(names)
		console.info(codes)
	},
	renderHtml: function() {
		this.initParam();
		let searcher = Searcher.searcher;
		//关键词
		$('#search-input').val(searcher.text);
		//价格
		if (!bbk.isEmpty(searcher.priceStart) && !bbk.isEmpty(searcher.priceEnd)) {
			$('#param-price-start').val(searcher.priceStart);
			$('#param-price-end').val(searcher.priceEnd);
			ParamerNav.add('价格:' + searcher.priceStart + '-' + searcher.priceEnd)
		}
		var priceAcBtn = {
			id: 'param-price-btn-box',
			names: ['0~3千', '3千~6千', '6千~8千', '8千~1.5万', '1.5万以上'],
			isSingle: true,
			click: function(name) {
				switch (name) {
					case '0~3千':
						Searcher.searcher.priceStart = 0;
						Searcher.searcher.priceEnd = 3000;
						ParamerNav.add('价格:' + name);
						break;
					case '3千~6千':
						Searcher.searcher.priceStart = 3000;
						Searcher.searcher.priceEnd = 6000;
						ParamerNav.add('价格:' + name);
						break;
					case '6千~8千':
						Searcher.searcher.priceStart = 6000;
						Searcher.searcher.priceEnd = 8000;
						ParamerNav.add('价格:' + name);
						break;
					case '8千~1.5万':
						Searcher.searcher.priceStart = 8000;
						Searcher.searcher.priceEnd = 15000;
						ParamerNav.add('价格:' + name);
						break;
					case '1.5万以上':
						Searcher.searcher.priceStart = 15000;
						Searcher.searcher.priceEnd = 10000000;
						ParamerNav.add('价格:' + name);
						break;
				}
				$('.param-price').val('');
				if (bbk.isEmpty(name)) {
					ParamerNav.remove('价格');
				}
			}
		}
		AcBtn.render(priceAcBtn);
		// let allLieBtn = {
		// 	id: 'param-lei-all-box',
		// 	names: ['全选'],
		// 	isSingle: true,
		// 	click: function(name) {
		// 		leis = [];
		// 		if (!bbk.isEmpty(name)) {
		// 			for (let i = 1; i <= 45; i++) {
		// 				leis.push(i);
		// 			}
		// 			AcBtn.chooseAll('param-lei-box');
		// 		} else {
		// 			AcBtn.clearChoosed('param-lei-box');
		// 			Searcher.searcher.teams.removeAll();
		// 		}
		// 		Searcher.searcher.leis = leis;
		// 		//群组
		// 	}
		// }
		// AcBtn.render(allLieBtn);
		//产品/服务
		$('#param-goods-input').val(searcher.goods);
		//商标类别
		let leiNames = ['01-化学原料', '02-颜料油漆', '03-日化用品', '04-燃料油脂', '05-医药医药', '06-金属材料', '07-机械设备',
			'08-手工器械',
			'09-科学仪器', '10-医疗器械', '11-灯具空调', '12-运输工具', '13-军火烟火', '14-珠宝钟表', '15-乐器乐器',
			'16-办公用品',
			'17-橡胶制品', '18-皮革皮具', '19-建筑材料', '20-家具家具', '21-厨房洁具', '22-绳网袋蓬', '23-纱线丝带',
			'24-布料床单',
			'25-服装鞋帽', '26-钮扣拉链', '27-地毯席垫', '28-健身器材', '29-食品食品', '30-方便食品', '31-农林生鲜',
			'32-啤酒饮料',
			'33-酒酒酒酒', '34-烟草烟具', '35-广告销售', '36-金融物管', '37-建筑修理', '38-通讯服务', '39-运输贮藏',
			'40-材料加工',
			'41-教育娱乐', '42-科技服务', '43-餐饮住宿', '44-医疗园艺', '45-社会服务', '全选'
		]
		let defLeiNames = [];
		if (!bbk.isEmpty(searcher.leis)) {
			for (let i = 0; i < leiNames.length; i++) {
				for (let j = 0; j < searcher.leis.length; j++) {
					if (leiNames[i].indexOf(searcher.leis[j]) > -1) {
						defLeiNames.add(leiNames[i]);
					}
				}
			}
			ParamerNav.add('类别:' + searcher.leis)
			//群组
			Paramer.showTeamBox();
		}
		var leiAcBtn = {
			id: 'param-lei-box',
			names: leiNames,
			default: defLeiNames,
			isSingle: false,
			click: function(name, names, isChoose) {

				let leis = [];
				for (let i = 0; i < names.length; i++) {
					let l = names[i].split('-')[0];
					leis.push(l);
				}
				leis.sort(); //排序
				if (name == '全选') {
					leis = [];
					if (isChoose) {
						for (let i = 1; i <= 45; i++) {
							leis.push(i);
						}
						AcBtn.chooseAll('param-lei-box');
					} else {
						AcBtn.clearChoosed('param-lei-box');
						Searcher.searcher.teams.removeAll();
					}
				}
				Searcher.searcher.leis = leis;
				//群组
				Paramer.showTeamBox();
				if (!isChoose) {
					//取消类的选择
					let teams = Cons.getTeams(parseInt(name));
					if (!bbk.isEmpty(teams)) {
						for (let i = 0; i < teams.length; i++) {
							Searcher.searcher.teams.remove(teams[i]);
						}
					}
				}
				ParamerNav.add('群组:' + Searcher.searcher.teams);
				if (leis.length == 0) {
					ParamerNav.remove('类别');
				} else {
					leis.remove('全选');
					ParamerNav.add('类别:' + leis);
				}
			}
		}
		AcBtn.render(leiAcBtn);
		//注册人申请量
		if (!bbk.isEmpty(searcher.sqNum)) {
			ParamerNav.add('注册人申请量:' + searcher.sqNum);
			let sqNums = searcher.sqNum.split("-");
			$('#param-sq-num-start').val(sqNums[0])
			$('#param-sq-num-end').val(sqNums[1])
		}
		let sqNumAcBtn = {
			id: 'param-sq-num-box',
			names: ['1-10', '1-20', '1-30', '1-50', '1-100', '101-999'],
			default: [searcher.sqNum],
			isSingle: true,
			click: function(name, names) {
				if (bbk.isEmpty(name)) {
					ParamerNav.remove('注册人申请量');
				} else {
					Searcher.searcher.sqNum = name;
					ParamerNav.add('注册人申请量:' + name);
				}
				$('#param-sq-num-start').val('');
				$('#param-sq-num-end').val('');
			}
		}
		//AcBtn.render(sqNumAcBtn);
		//组合类型
		let defTypeNames = [];
		if (!bbk.isEmpty(searcher.types)) {
			for (let i = 0; i < searcher.types.length; i++) {
				switch (searcher.types[i]) {
					case 1:    
						defTypeNames.add('纯中文');
						break;
					case 2:
						defTypeNames.add('纯英文');
						break;
					case 3:
						defTypeNames.add('中文+英文');
						break;
					case 4:
						defTypeNames.add('纯数字');
						break;
					case 5:
						defTypeNames.add('中文+数字');
						break;
					case 6:
						defTypeNames.add('英文+数字');
						break;
					case 8:
						defTypeNames.add('纯图形');
						break;
					


				}
			}
			console.info(defTypeNames)
			ParamerNav.add('组合类型:' + defTypeNames)
		}
		var typeAcBtn = {     
			id: 'param-type-box',
			names: ['纯中文', '纯英文', '中文+英文', '纯数字', '中文+数字', '英文+数字', '纯图形'],
			default: defTypeNames,
			click: function(name, names) {
				let searcher = Searcher.searcher;
				if (bbk.isEmpty(names)) {
					ParamerNav.remove('组合类型');
					searcher.types = undefined;
				} else {
					ParamerNav.add('组合类型:' + names);
					searcher.types = [];
					for (let i = 0; i < names.length; i++) {
						switch (names[i]) {
							case '纯中文':
								searcher.types.add(1);
								break;
							case '纯英文':
								searcher.types.add(2);
								break;
							case '中文+英文':
								searcher.types.add(3);
								break;
							case '纯数字':
								searcher.types.add(4);
								break;
							case '中文+数字':
								searcher.types.add(5);
								break;
							case '英文+数字':
								searcher.types.add(6);
								break;
							case '纯图形':
								searcher.types.add(8);
								break;
							
							default:
								Msger.error('组合类型的出现未知的类型「' + names[i] + '」,请反馈给我1,谢谢')
						}
					}
				}
			}
		}
		AcBtn.render(typeAcBtn);

		//名称结构:
		if (!bbk.isEmpty(searcher.abTypes)) {
			ParamerNav.add('名称结构:' + searcher.abTypes);
		}     

		let abTypeAcbtn = {
			id: 'param-ab-type-box',
			names: ['AA', 'AB', 'ABB', 'AAB', 'AAA', 'AAAA', 'AABB', 'ABAB', 'ABBB', 'AAAB', 'ABAC',
				'AABC',
				'ABCC'
			],
			default: searcher.abTypes,
			click: function(name, names) {
				Searcher.searcher.abTypes = names;
				if (bbk.isEmpty(names)) {
					ParamerNav.remove('名称结构');
				} else {
					ParamerNav.add('名称结构:' + name);
				}

			}
		}
		//AcBtn.render(abTypeAcbtn);
		//商标字数
		let defnameSize = [];
		let nameSize= ['1个字', '2个字', '3个字', '4个字', '5个字', '6个字', '7个字', '8个字', '9个字', '10个字'];
		if (!bbk.isEmpty(searcher.nameSize)) {
			for (let i = 0; i < nameSize.length; i++) {
				for (let j = 0; j < searcher.nameSize.length; j++) {
					if (searcher.nameSize[j] == Reg.findNum(nameSize[i])) {
						defnameSize.add(nameSize[i]);
					}
				}
			}
			ParamerNav.add('字数:' + searcher.nameSize)
		}
		var sizeAcBtn = {
			id: 'param-name-size-box',
			names: nameSize,
			default: defnameSize,
			click: function(name, names) {
				if (names.length > 0) {
					let nameSize = [];
					for (let i = 0; i < names.length; i++) {
						nameSize.add(parseInt(names[i]));
					}
					ParamerNav.add('字数:' + nameSize);
					Searcher.searcher.nameSize = nameSize;
				} else {
					ParamerNav.remove('字数');
					Searcher.searcher.nameSize = '';
				}
			}
		}
		AcBtn.render(sizeAcBtn);
		//小项不少于:
		let xxNumStartAcbtn = {
			id: 'param-xx-num-start-box',
			isSingle: true,
			names: ['1', '3', '5', '8', '10'],
			default: [searcher.xxNumStart],
			click: function(name) {
				if (bbk.isEmpty(name)) {
					Searcher.searcher.xxNumStart = '';
					ParamerNav.remove('小项不少于');
				} else {
					Searcher.searcher.xxNumStart = name;
					ParamerNav.add('小项不少于:' + name);
				}
			}
		}
		//AcBtn.render(xxNumStartAcbtn);


		//申请人
		//申请人
		let defBlackSqNamers = [];
		if(!bbk.isEmpty(searcher.blackSqNamers)){
			for(let i=0;i<searcher.blackSqNamers.length;i++){
				switch(searcher.blackSqNamers[i]){
					case 0:
					defBlackSqNamers.add('正常');
					break;
					case 1:
					defBlackSqNamers.add('暂缓转让');
					break;
					case 3:
					defBlackSqNamers.add('仅授权');
					break;
				}
			}
		}
		defBlackSqNamers=bbk.isEmpty(defBlackSqNamers)?['正常']:defBlackSqNamers;
		Searcher.setBlackSqNamers(defBlackSqNamers);
		let blackSqNamerAcBtn = {
			id: 'param-black-sq-namer-box',
			names: ['正常','暂缓转让','仅授权'],
			default: defBlackSqNamers,
			click: function(name, names) {
				Searcher.setBlackSqNamers(names);
			}
		}
	   //AcBtn.render(blackSqNamerAcBtn);
		//申请人类型
		let defSqTypeNames = []
		if (!bbk.isEmpty(searcher.sqType)) {
			if (searcher.sqType == 1) {
				defSqTypeNames.add('仅个人')
			}
			if (searcher.sqType == 2) {
				defSqTypeNames.add('仅公司')
			}
			ParamerNav.add('申请人类型:' + defSqTypeNames)
		}
		let sqTypeAcBtn = {
			id: 'param-sq-type-box',
			names: ['仅公司', '仅个人'],
			default: defSqTypeNames,
			isSingle: true,
			click: function(name) {
				if (bbk.isEmpty(name)) {
					ParamerNav.remove('申请人类型');
				} else {
					ParamerNav.add('申请人类型:' + name);
					switch (name) {
						case '仅公司':
							Searcher.searcher.sqType = 2;
							break;
						case '仅个人':
							Searcher.searcher.sqType = 1;
							break;
					}
				}
			}
		}
		//AcBtn.render(sqTypeAcBtn);
		//排序
		let deforderByNames = []
		if (!bbk.isEmpty(searcher.orderBy)) {
			if (searcher.orderBy == 0) {
				deforderByNames.add('默认')
			}
			if (searcher.orderBy == 1) {
				deforderByNames.add('价格由低到高')
			}
			ParamerNav.add('排序:' + deforderByNames)
		}
		let orderByAcBtn = {
			id: 'param-order-by-box',
			names: ['默认', '价格由低到高'],
			default: deforderByNames,
			isSingle: true,
			click: function(name) {
				if (bbk.isEmpty(name)) {
					ParamerNav.remove('排序');
				} else {
					ParamerNav.add('排序:' + name);
					switch (name) {
						case '默认':
							Searcher.searcher.orderBy = 0;
							break;
						case '价格由低到高':
							Searcher.searcher.orderBy = 1;
							break;
					}
				}
			}
		}
		AcBtn.render(orderByAcBtn);
		//是否同名标仅显示一个类别
		let defdistinctNames = []
		if (!bbk.isEmpty(searcher.distinct)) {
			if (searcher.distinct == 0) {
				defdistinctNames.add('否')
			}
			if (searcher.distinct == 1) {
				defdistinctNames.add('是')
			}
			ParamerNav.add('是否同名标仅显示一个类别:' + defdistinctNames)
		}
		let distinctAcBtn = {
			id: 'param-distinct-box',
			names: ['否', '是'],
			default: defdistinctNames,
			isSingle: true,
			click: function(name) {
				if (bbk.isEmpty(name)) {
					ParamerNav.remove('是否同名标仅显示一个类别');
				} else {
					ParamerNav.add('是否同名标仅显示一个类别:' + name);
					switch (name) {
						case '否':
							Searcher.searcher.distinct = 0;
							break;
						case '是':
							Searcher.searcher.distinct = 1;
							break;
					}
				}
			}
		}
		AcBtn.render(distinctAcBtn);
		//注册年限
		if (!bbk.isEmpty(searcher.age)) {
			ParamerNav.add('年限:' + searcher.age)
		}
		var ageAcBtn = {
			id: 'param-age-box',
			names: ['1年以内', '1年-2年', '2年-3年', '3年以上'],
			isSingle: true,
			default: [searcher.age],
			click: function(name) {
				if (bbk.isEmpty(name)) {
					ParamerNav.remove('年限');
				} else {
					ParamerNav.add('年限:' + name);
					Searcher.searcher.age = name;
				}
				let s = Searcher.searcher;
				switch (name) {
					case '1年以内':
						s.ageStart = 0;
						s.ageEnd = 1;
						break;
					case '1年-2年':
						s.ageStart = 1;
						s.ageEnd = 2;
						break;
					case '2年-3年':
						s.ageStart = 2;
						s.ageEnd = 3;
						break;
					
					case '3年以上':
						s.ageStart = 3;
						s.ageEnd = '';
						break;
					default:
						s.ageStart = '';
						s.ageEnd = '';
				}
			}
		}
		//AcBtn.render(ageAcBtn);

	},
	initTiper: function() {
		let tiper = {
			id: 'param-goods-input'
		}
		InputTiper.init(tiper);
	},
	initSearchMode: function() {
		let searchModes = [{
			title: '开头包含',
			code: 1
		}, {
			title: '结尾包含',
			code: 2
		}, {
			title: '模糊搜索(默认)',
			code: 0
		}, {
			title: '包含全部',
			code: 3
		}, {
			title: '精准搜索',
			code: 4
		}];
		layui.dropdown.render({
			elem: '#search-mode',
			data: searchModes,
			click: function(data, othis) {
				$(this.elem).html(data.title);
				$(this.elem).css('color', '#fff').css('background', '#5FB878');
				Searcher.searcher.searchMode = data.code;
			}
		});
	},
	initBuyer: function() {
		if (bbk.isBuyer()) {
			$('.buyer-hide').css('display', 'none');
		}
	},
	init: function() {
		Hoster.init(function(hoster) {
			//document.title = hoster.name + '手机版';
			if (hoster.baseColor) {
				Searcher.searchVue.data.theme.baseColor = hoster.baseColor;
			}
			MobileNav.init();
			if (!hoster.showPrice) {
				$('.param-item-box-price').css('display', 'block');
			} else {
				$('.param-item-box-price').css('display', 'block');
			}
			if (hoster.defSqNum) {
				Searcher.searcher.sqNum = hoster.defSqNum;
				$('.param-item-box-sq-num').css('display', 'block');
			} else {
				$('.param-item-box-sq-num').css('display', 'block');
				Searcher.searcher.sqNum = undefined;
			}
		});
		this.initUrlVal();
		this.initVue();
		this.renderHtml();
		Toper.init();
		this.doSearch();
		// // this.initTiper();
		// this.initTotal();
		// this.initBuyer();
	},
	//搜索开始
	start: function() {
		$('#search-btn').html(
			'<i class="layui-icon-loading-1 layui-icon layui-anim layui-anim-rotate layui-anim-loop"></i>');
		Logo.jump('.index-logo-box');
		this.flag.isLoading = true;
		$('.none-result').html('正在搜索...').css('display', 'flex');
	},
	finish: function() {
		$('#search-btn').html('搜 索');
		Logo.stop('.index-logo-box');
		this.flag.isLoading = false;
		if (bbk.isEmpty(Searcher.items)) {
			let html = '没有查询到任何结果,请更换搜索条件「' + Searcher.searcher.text + '」';
			if (Reg.isBrandId(Searcher.searcher.text) && !bbk.isBuyer() && Searcher.searcher.page == 'index' &&
				(Searcher.searcher.textType == '智能' || Searcher.searcher.textType == '注册号')) {
				html += '<span onclick="Searcher.searchOff()" style="cursor:pointer;color:blue"> 点我深度搜索</span>';
			}
			$('.none-result').html(html).css('display', 'flex');
		} else {
			$('.none-result').css('display', 'none');
		}
	},
	//深度搜索
	searchOff: function() {
		let ajax = {
			url: '/deep-search',
			data: {
				brandId: Searcher.searcher.text
			},
			success: function(res) {
				console.info(res);
				Msger.talk(res.msg);
				return false;
			},
		}
		Msger.info('正在查询');
		bbk.ajax(ajax);
	},
	randerPage: function() {
		layui.use('laypage', function() {
			var laypage = layui.laypage;
			//执行一个laypage实例
			laypage.render({
				elem: 'laypage-box', //注意，这里的 test1 是 ID，不用加 # 号
				count: Searcher.total, //数据总数，从服务端得到
				limits: [90],
				groups: 3,
				theme: '#3f56e0',
				layout: ['count', 'page', 'prev', 'next', 'skip'],
				limit: Searcher.searcher.limit,
				jump: function(obj, first) {
					//首次不执行
					if (!first) {
						Searcher.searcher.current = obj.curr;
						Searcher.searcher.limit = obj.limit;
						Searcher.doSearch(1);
					}
				}
			});
		});
	},
	//fromFlag 1=>laypage  2=>batchSearch
	doSearch: function(fromFlag) {
		if (fromFlag != 1) {
			Searcher.searcher.current = 1;
		} else {
			Toper.doTop();
		}
		let ajax = {
			url: 'https://www.dunmama.cn/index/search.html',
			data: Searcher.searcher,
			success: function(res) {
				let branders = res.data.results;
				Searcher.total = res.data.total;
				//清空
				Searcher.items.removeAll();
				$('.choose-btn').css('color', '#222').css('background', '');
				if( res.data.total > 0 ){
					for (let i = 0; i < branders.length; i++) {
						Searcher.items.push(branders[i]);
					}
				}
				if (bbk.isEmpty(fromFlag)) {
					Searcher.randerPage();
					//有必要
					$('#laypage-box').css('display', 'block');
				} else if ( fromFlag == 2) {
					$('#laypage-box').css('display', 'none');
					if( res.data.total > 0 ) {
						Msger.info('查询到' + branders.length + '个商标');
					}else{
						Msger.info('查询到0个商标');
					}
				}
				Searcher.finish();
				ChooseItemer.renderAllBtn();
				Searcher.hideParam();
				Searcher.resTip(branders);
			},
			error: function(res) {
				console.info(res);
				Searcher.finish();
				if (res.code == Cons.ERROR_CODE.NOT_LOGIN) {
					Login.login(false, function() {
						Searcher.doSearch();
					});
					return false;
				}
			}
		}
		this.start();
		bbk.ajax(ajax);
	},

	resTip: function(branders) {
		if (branders.length == 0) {
			$('#res-tip-box').html("<br>没有符合条件的商标<br><br>请点击「输入框」重新设置搜索条件!<br>").css('display', 'block');
		} else {
			$('#res-tip-box').css('display', 'none');
		}
	},
	inputClear: function() {
		$('#search-input').val('');
		$('.search-input-close-icon').css('color', '#fff');
	},
	onfocus: function() {
		$('.search-param-box').removeClass('search-param-box-anim-up').addClass('search-param-box-anim-down')
			.css("display", "block");
		$('.bbk-shade').removeClass('layui-anim-fadeout').addClass('layui-anim-fadein').css('display', 'block');
		// $('.bbk-shade').css('display','block');

	},
	hideParam: function() {
		$('.bbk-shade').css('display', 'none');
		$('.search-param-box').removeClass('search-param-box-anim-down').addClass('search-param-box-anim-up');
		$('.bbk-shade').removeClass('layui-anim-fadein').addClass('layui-anim-fadeout');
		setTimeout(function() {
			$('.search-param-box').css("display", 'none');
		}, 450)
	},

}
//条件导航
ParamerNav = {
	names: [],
	add: function(name) {
		let label = name.split(':')[0];
		let content = name.split(':')[1];
		if (bbk.isEmpty(content)) {
			this.remove(label);
			return;
		}
		let isExit = false;
		for (let i = 0; i < this.names.length; i++) {
			if (this.names[i].split(':')[0] == label) {
				this.names[i] = name;
				isExit = true;
			}
		}
		if (!isExit) {
			this.names.push(name);
		}
		// this.render();
	},
	//清空总按钮
	removeAll: function() {
		while (this.names.length > 0) {
			this.remove(this.names[0].split(":")[0]);
		}
		ChooseItemer.removeAll();
		Searcher.inputClear();
		Msger.info('已清空');
		if (bbk.getUrlVal('from') == 'buyer_site_url') {
			bbk.setUrlVal('from', '')
		}
	},
	remove: function(label) {
		for (let i = 0; i < this.names.length; i++) {
			if (this.names[i].indexOf(label) > -1) {
				this.names.splice(i, 1);
				i = this.names.length;
				// this.render();
			}
		}
		let searcher = Searcher.searcher;
		switch (label) {
			case '价格':
				searcher.priceStart = '';
				searcher.priceEnd = '';
				$('#param-price-start').val('');
				$('#param-price-end').val('');
				AcBtn.clearChoosed('param-price-btn-box');
				break;
			case '类别':
				searcher.leis = [];
				AcBtn.clearChoosed('param-lei-box');
				searcher.teams = [];
				ParamerNav.remove('群组');
				Paramer.showTeamBox();
				break;
			case '群组':
				searcher.teams = [];
				for (let i = 1; i < 46; i++) {
					AcBtn.clearChoosed('param-team-' + i);
				}
				break;
			case '产品/服务':
				searcher.goods = '';
				$('#param-goods-input').val('');
				break;
			case '组合类型':
				searcher.type = '';
				AcBtn.clearChoosed('param-type-box');
				break;
//			case '名称结构':
//				searcher.abTypes = [];
//				AcBtn.clearChoosed('param-ab-type-box');
//				break;
			case '字数':
				searcher.nameSizeList = '';
				AcBtn.clearChoosed('param-name-size-box');
				break;
//			case '小项不少于':
//				searcher.xxNumStart = '';
//				AcBtn.clearChoosed('param-xx-num-start-box');
//				break;
//			case '注册人申请量':
//				searcher.sqNum = undefined;
//				AcBtn.clearChoosed('param-sq-num-box');
//				break;
// 			case '申请人类型':
// 				searcher.sqType = '';
// 				AcBtn.clearChoosed('param-sq-type-box');
// 				break;
// 			case '年限':
// 				searcher.age = '';
// 				searcher.ageStart = '';
// 				searcher.ageEnd = '';
// 				AcBtn.clearChoosed('param-age-box');
// 				break;
 			case '排序':
 				searcher.orderBy = '';
 				AcBtn.clearChoosed('param-order-by-box');
 				break;
			case '是否同名标仅显示一个类别':
				searcher.distinct = '';
				AcBtn.clearChoosed('param-distinct-box');
				break;
			case '保留暂时无法转让的商标':
				AcBtn.clearChoosed('param-black-sq-namer-box');
				//这里有点绕blackSqNamer为0不保留暂不转让，未空则保留
				searcher.blackSqNamer = '';
				break;
		}
	},
	// render: function() {
	// 	let acBtn = {
	// 		id: 'search-param-nav-box',
	// 		names: ParamerNav.names,
	// 		canClose: true,
	// 		close: function(name, names) {
	// 			let label = name.split(':')[0];
	// 			ParamerNav.remove(label);
	// 		}
	// 	}
	// 	AcBtn.render(acBtn);
	// 	if (ParamerNav.names.length > 0) {
	// 		$('.clear-btn').css('display', 'block');
	// 	} else {
	// 		$('.clear-btn').css('display', 'none');
	// 	}
	// },

}

Paramer = {
	showMore: function() {
		if ($('.param-more-box').css('display') == 'none') {
			$('.param-more-box').css('display', 'block');
			$('.param-more-btn').html('隐藏选项<i class="layui-icon-up layui-icon"></i>');
		} else {
			$('.param-more-box').css('display', 'none');
			$('.param-more-btn').html('更多选项<i class="layui-icon-down layui-icon"></i>');
		}


	},
	price: function(flag, obj) {
		let start = bbk.getVal('param-price-start');
		let end = bbk.getVal('param-price-end');

		Searcher.searcher.priceStart = bbk.getPrice(start);
		Searcher.searcher.priceEnd = bbk.getPrice(end) == 0 ? '1000000' : bbk.getPrice(end);
		ParamerNav.add('价格:' + Searcher.searcher.priceStart + ' - ' + Searcher.searcher.priceEnd);
		AcBtn.clearChoosed('param-price-btn-box');
	},
	// showLeiBox: function(obj) {
	// 	if (bbk.isEmpty(obj.id)) {
	// 		$('#param-lei-box').css('height', 'auto');
	// 		$('.param-lei-more').children('span').html('收起');
	// 		obj.id = 'auto';
	// 	} else {
	// 		$('#param-lei-box').css('height', '37px');
	// 		$('.param-lei-more').children('span').html('展开');
	// 		obj.id = '';
	// 	}
	// },
	showTeamBox: function() {
		let leis = Searcher.searcher.leis;
		if (leis.length == 0) {
			$('#param-team-00').css('display', 'block');
		} else {
			$('#param-team-00').css('display', 'none');
		}
		for (let i = 1; i < 46; i++) {
			if (leis.indexOf(i) > -1) {
				if (bbk.isEmpty($('#param-team-' + i).html())) {
					AcBtn.render({
						id: 'param-team-' + i,
						names: Cons.getTeams(i),
						default: Searcher.searcher.teams,
						titles: Cons.getTitles(i),
						click: function(name, names, isChoose) {
							let teams = Searcher.searcher.teams;
							if (isChoose) {
								teams.add(name);
							} else {
								teams.remove(name);
								teams.sort();
							}
							teams.sort();
							if (teams.length == 0) {
								ParamerNav.remove('群组');
							} else {
								ParamerNav.add('群组:' + teams);
							}
						}
					});
				}
			} else {
				$('#param-team-' + i).html('');
			}
		}
	},
	goods: function() {
	    
	    let goods = bbk.getVal('param-goods-input');
		let goodsArr = [];
		goods = goods.split(' ');
		for (let i = 0; i < goods.length; i++) {
			if (!bbk.isEmpty(goods[i])) {
				goodsArr.push(goods[i]);
			}
		}
		Searcher.searcher.goods = goodsArr;
		ParamerNav.add('产品/服务:' + goodsArr);
	    /*
		Searcher.searcher.goods = bbk.getVal('param-goods-input');
		ParamerNav.add('产品/服务:' + Searcher.searcher.goods);*/
	},
	show: function() {
		$('.search-param-box').css('display', 'block');
		$('.param-hide-btn').html('保持显示');
		$('.search-param-nav-box').css('min-height', '37px');

	},
	hide: function() {
		if (localStorage.INDEX_PARAM_AUTO_HIDDEN == 1) {
			localStorage.INDEX_PARAM_AUTO_HIDDEN = 0;
			Msger.info('设置成功');
			$('.param-hide-btn').html('自动隐藏');
			return;
		}
		Msger.isSure("提示:下次点击「输入框」会自动显示哦~", function() {
			$('.search-param-box').css('display', 'none');
			$('.search-param-nav-box').css('min-height', '0px');
			localStorage.INDEX_PARAM_AUTO_HIDDEN = 1;
		})

	},
	batchSearch: function() {
		// if (Searcher.searcher.page != Cons.PAGE.INDEX && Searcher.searcher.page != Cons.PAGE.MY_BRANDER_ON &&
		// 	Searcher.searcher.page != Cons.PAGE.MY_BRANDER_OFF && Searcher.searcher.page != Cons.PAGE
		// 	.MY_BRANDER_SOLD) {
		// 	// Msger.info('当前页面不支持批量搜索');
		// 	// return;
		// }
		Msger.text('请输入商标号(最多500个):', function(text) {
			text = text.replace(new RegExp('\n', "g"), '-bbk-')
				.replace(new RegExp('\t', "g"), '-bbk-').replace(new RegExp(' ', "g"), '-bbk-');
			let arr = text.split('-bbk-');
			let brandIds = [];
			for (let i = 0; i < arr.length; i++) {
				arr[i] = bbk.trim(arr[i]);
				if (Reg.isBrandId(arr[i])) {
					brandIds.add(arr[i]);
				}
			}
			if (brandIds.length > 500) {
				Msger.error('商标个数超过500个上限,当前商标数量为:' + brandIds.length)
				return;
			}
			if (brandIds.length == 0) {
				console.info(text);
				Msger.info('未获得有效商标号');
				return;
			}
			Searcher.searcher.brandIds = brandIds;
			Searcher.doSearch(2);
			Searcher.searcher.brandIds = undefined;
			$('#laypage-box').css('display', 'none');
		}, true)
	},
	createBuyerSiteUrl: function() {
		if (Searcher.searcher.page != 'index') {
			Msger.talk('请在「全网」页面下进行此操作，如有疑问请联系客服');
			return;
		}
		let changePrice = false;
		let ajax = {
			url: '/buyer-site-url/create-url',
			data: {
				searcher: JSON.stringify(Searcher.searcher)
			},
			success: function(res) {
				Msger.isSure('确定复制?', function() {
					bbk.copy('https://' + location.host + "/html/buyer_site_url.html?url=" + res.data);
				});
			}
		}
		bbk.ajax(ajax);
	}
}

//每个页面选择的商标独立
ChooseItemer = {
	ids: [],
	getName: function() {
		switch (Searcher.searcher.page) {
			case Cons.PAGE.SAVER:
				return '「我的收藏」';
			default:
				return '';
		}
	},
	//永久保存
	save: function() {
		switch (Searcher.searcher.page) {
			case Cons.PAGE.INDEX:
				localStorage.INDEX_IDS = JSON.stringify(this.ids);
				break;
			case Cons.PAGE.TEAMER_ON:
				localStorage.TEAMER_ON_IDS = JSON.stringify(this.ids);
				break;
			case Cons.PAGE.TEAMER_SOLD:
				localStorage.TEAMER_SOLD_IDS = JSON.stringify(this.ids);
				break;
			case Cons.PAGE.MY_BRANDER_ON:
				localStorage.MY_ON_IDS = JSON.stringify(this.ids);
				break;
			case Cons.PAGE.MY_BRANDER_SOLD:
				localStorage.MY_SOLD_IDS = JSON.stringify(this.ids);
				break;
			case Cons.PAGE.MY_BRANDER_OFF:
				localStorage.MY_OFF_IDS = JSON.stringify(this.ids);
				break;
			case Cons.PAGE.MY_BRANDER_ERROR:
				localStorage.MY_ERROR_IDS = JSON.stringify(this.ids);
				break;
			case Cons.PAGE.SAVER:
				localStorage.SAVER_IDS = JSON.stringify(this.ids);
				break;
		}
		this.renderIoBox();
	},
	add: function(id) {
		if (ChooseItemer.ids.length < 1000) {
			ChooseItemer.ids.add(id);
			this.save();
		} else {
			Msger.info('已超过1000个上限');
		}
	},
	remove: function(id) {
		ChooseItemer.ids.remove(id);
		this.save();
	},
	removeAll: function() {
		ChooseItemer.ids.removeAll();
		this.save();
		this.clear();
	},
	isChoosed: function(id) {
		return ChooseItemer.ids.indexOf(id) > -1;
	},
	//是否当页已全选
	renderAllBtn: function() {
		let isAll = true;
		for (let i = 0; i < Searcher.items.length; i++) {
			if (ChooseItemer.ids.indexOf(Searcher.items[i].id) == -1) {
				isAll = false;
				break;
			}
		}
		if (isAll) {
			$('.choose-btn-all').css('color', '#fff').css('background', 'olivedrab');
			$('.choose-all-btn-box').css('border-color', 'olivedrab').css('color', 'olivedrab');
		} else {
			$('.choose-btn-all').css('color', '#222').css('background', '#fff');
			$('.choose-all-btn-box').css('border-color', '#e1e1e1').css('color', '#222');
		}
	},
	renderIoBox: function() {
		let length = ChooseItemer.ids.length;
		let name = this.getName();
		if (length > 0) {
			let ioBox = {
				title: '您勾选了<span class="io-box-num"> ' + length + ' </span>个' + name + '商标:',
				content: DataPartner.getDataBtns(),
				close: function() {
					ChooseItemer.removeAll();
					Msger.info('已清空');
				}
			}
			IoBox.render(ioBox);
			$('#my-brander-batch-box').css('display', 'none');
		} else {
			IoBox.close(true);
			$('#my-brander-batch-box').css('display', 'inline-block');
		}
		this.renderAllBtn();
	},
	click: function(obj) {
		let id = obj.id;
		if (obj == 'all') {
			obj = bbk.$('all');
			if (obj.style.background == 'olivedrab') {
				//全取消
				$('.choose-btn').css('color', '#222').css('background', '#fff');
				$('.result-item-cube-box').css('border-color', '#ddd');
				for (let i = 0; i < Searcher.items.length; i++) {
					this.remove(Searcher.items[i].id)
				}
			} else {
				//全选中
				$('.choose-btn').css('color', '#fff').css('background', 'olivedrab');
				for (let i = 0; i < Searcher.items.length; i++) {
					ChooseItemer.add(Searcher.items[i].id);
				}
			}
			localStorage.INDEX_CHOOSE_ALL_TIP = 1;
		} else {
			//取消选中
			if (obj.style.background == 'olivedrab') {
				obj.style.background = '#fff';
				obj.style.color = '#222';
				ChooseItemer.remove(id);
				$(obj).parent().parent().parent().css('border-color', '#ddd');
			} else {
				//选中
				obj.style.background = 'olivedrab';
				obj.style.color = '#fff';
				ChooseItemer.add(id);
			}

		}
	},
	clear: function() {
		$('.choose-btn').css('color', '#222').css('background', '');
		$('.result-item-cube-box').css('border-color', '#ddd');
	}
}
DataPartner = {
	getDataBtns: function() {
		let btnHtml;
		switch (Searcher.searcher.page) {
			case Cons.PAGE.TABLE:
				//「表格详情」
				btnHtml = '如需「改价」、「上架」、「删除」等操作,请点击<a class="blue" href="/?page=' + Cons.PAGE.MY_BRANDER_OFF +
					'">我的商标</a>';

				return btnHtml;
			case Cons.PAGE.SAVER:
				btnHtml =
					'<button onclick="DataPartner.delete()" class="layui-btn layui-btn-normal layui-btn-sm"><i class="layui-icon  layui-icon-star-fill"></i>取消收藏</button>' +
					'<button onclick="DataPartner.delete(true)" class="layui-btn layui-btn-primary layui-btn-sm"><i class="layui-icon  layui-icon-delete"></i>清空收藏</button>' +
					'<button onclick="DataPartner.export()" class="layui-btn layui-btn-normal layui-btn-sm"><i class="layui-icon  layui-icon-export"></i>导出(VIP)</button>' +
					'<a class="layui-btn layui-btn-normal layui-btn-sm" target="_blank" href="/mobile/cuber/cuber.html?from=saver"><i class="layui-icon  layui-icon-app"></i>制作九宫格</a>';
				return btnHtml;
			case Cons.PAGE.TEAMER_ON:
				//「已上架团队」
				btnHtml =
					'<a  class="layui-btn layui-btn-normal layui-btn-sm" target="_blank" href="/mobile/cuber/cuber.html?from=teamer_on"><i class="layui-icon  layui-icon-app"></i>制作九宫格</a>' +
					'<button  onclick="DataPartner.export()" class="layui-btn layui-btn-normal layui-btn-sm"><i class="layui-icon  layui-icon-export"></i>导出(VIP)</button>' +
					'<button  onclick="DataPartner.sold()" class="layui-btn layui-btn-danger layui-btn-sm"><i class="layui-icon  layui-icon-release"></i>已卖出</button>' +
					'<button onclick="DataPartner.save()" class="layui-btn layui-btn-normal layui-btn-sm"><i class="layui-icon  layui-icon-star"></i>收藏</button>';
				return btnHtml;
			case Cons.PAGE.INDEX:
				//「公开」
				btnHtml =
					'<a  class="layui-btn layui-btn-normal layui-btn-sm " target="_blank" href="/mobile/cuber/cuber.html?from=index"><i class="layui-icon  layui-icon-app"></i>制作九宫格</a>' +
					'<button  onclick="DataPartner.export()" class="layui-btn layui-btn-normal layui-btn-sm"><i class="layui-icon  layui-icon-export"></i>导出(VIP)</button>' +
					'';
				return btnHtml;
			case Cons.PAGE.SIMPLE_LIST:
				//「公开」
				btnHtml =
					'<a  class="layui-btn layui-btn-normal layui-btn-sm " target="_blank" href="/mobile/cuber/cuber.html?from=index"><i class="layui-icon  layui-icon-app"></i>制作九宫格</a>' +
					'<button   onclick="DataPartner.export()" class="layui-btn layui-btn-normal layui-btn-sm"><i class="layui-icon  layui-icon-export"></i>导出(VIP)</button>' +
					'<button onclick="DataPartner.save()" class="layui-btn layui-btn-normal layui-btn-sm"><i class="layui-icon  layui-icon-star"></i>收藏</button>';
				if (bbk.getUser().id == 100001) {
					btnHtml +=
						'<button class="layui-btn layui-btn-danger layui-btn-sm" onclick="DataPartner.sameName()"><i class="layui-icon  layui-icon-group"></i>设为同名</button>';
					btnHtml +=
						'<button class="layui-btn layui-btn-danger layui-btn-sm" onclick="DataPartner.resetMd()"><i class="layui-icon  layui-icon-unlink"></i>重置MD</button>';
				}
				return btnHtml;

		}
	},
	export: function() {
		let content =
			'<div class="export-batch-box">' +
			'<div class="export-batch-line export-batch-first-line line">' +
			'<div class="export-batch-label left">导出范围：</div>' +
			'<div id="export-batch-size-box" class="left"><span class="export-batch-label">您勾选的<span class="io-box-num"> ' +
			ChooseItemer.ids.length + ' </span>个' + ChooseItemer.getName() + '商标<span></div>' +
			'</div>' +
			'<div class="export-batch-line line" style="margin-top:10px">' +
			'<div class="export-batch-label left">价格调高：</div>' +
			'<div class="export-batch-price-box left">' +
			'<input onclick="DataPartner.clearPrice(2)" id="export-batch-fixed-price" class="bbk-input export-batch-price-input"  />&ensp;元&ensp;&ensp;&ensp;or&ensp;&ensp;&ensp;' +
			'<input onclick="DataPartner.clearPrice(1)" id="export-batch-percent-price" class="bbk-input export-batch-price-input" placeholder="1-100" />&ensp;%</div>' +
			'</div>' +
			'</div>' +
			'<div id="export-more-box" class="hidden flex-center"></div>';
		if (Searcher.searcher.page == Cons.PAGE.INDEX) {
			content += '<div style="text-align:center;font-size:14px;color:orange;">说明:「全网」商标至少加价500元</div>';
		}
		var layer = layui.layer;
		layer.open({
			title: '导出:',
			type: 1,
			resize: false,
			content: content,
			shadeClose: true,
			area: '98%',
			btn: ['导出(VIP)', '取消'],
			btn1: function() {
				let searcher = Searcher.searcher;
				if (Searcher.searcher.noNames.indexOf('不含价格') == -1) {
					let fixedPrice = bbk.getVal('export-batch-fixed-price');
					if (!bbk.isEmpty(fixedPrice)) {
						if (!Reg.isNum(fixedPrice)) {
							Msger.info('价格只能是数字');
							return;
						}
						searcher.fixedPrice = fixedPrice;
					}
					percentPrice = bbk.getVal('export-batch-percent-price');
					if (!bbk.isEmpty(percentPrice)) {
						if (!Reg.isNum(percentPrice)) {
							Msger.info('价格只能是数字');
							return;
						}
						searcher.percentPrice = percentPrice / 100;
					}
					//如果是全网页面
					if (Searcher.searcher.page == Cons.PAGE.INDEX) {
						if (bbk.isEmpty(fixedPrice) && bbk.isEmpty(percentPrice)) {
							Msger.info('「全网」页面导出时，「价格上调」不能为空');
							return;
						}
						if (!bbk.isEmpty(fixedPrice)) {
							if (fixedPrice < 500) {
								Msger.info('「全网」页面导出时，加价不能低于500!');
								return;
							}
						}

					}
				}

				searcher.ids = ChooseItemer.ids;
				let ajax = {
					url: '/export',
					data: searcher,
					success: function(res) {
						if (!bbk.isEmpty(res.data)) {
							// location.href = res.data;
							bbk.down(res.data);
						}
						Msger.closeClock();
						Msger.info("导出成功");
						return false;
					},
					error: function(res) {
						Msger.closeClock();
						if (res.code == Cons.ERROR_CODE.NOT_LOGIN) {
							Login.login(false, function() {
								let ajax2 = {
									url: '/export',
									data: Searcher.searcher,
									success: function(res) {
										if (!bbk.isEmpty(res
											.data)) {
											// location.href = res.data;
											bbk.down(res.data);
										}
										Msger.closeClock();
										Msger.info("导出成功");
										return false;
									},
									error: function() {
										Msger.closeClock();
									}
								}
								Msger.clockMsg('正在导出,请勿刷新...', ChooseItemer
									.ids
									.length /
									10 + 5);
								bbk.ajax(ajax2);
							});
							return false;
						}
					}
				}
				layui.layer.closeAll();
				Msger.clockMsg('正在导出,请勿刷新...', ChooseItemer.ids.length / 10 + 5);
				bbk.ajax(ajax);
			}
		});
		let acBtn = {
			id: 'export-more-box',
			names: ['不含价格', '不含图样'],
			click: function(name, names) {
				Searcher.searcher.noNames = names;
			}
		}
		Searcher.searcher.noNames = [];
		AcBtn.render(acBtn);
	},
	exportAll: function() {
		let ajax = {
			url: '/export-all',
			data: {
				page: Searcher.searcher.page
			},
			success: function(res) {
				if (!bbk.isEmpty(res.data)) {
					// location.href = res.data;
					bbk.down(res.data);
				}
				Msger.closeClock();
				Msger.info("导出成功");
				return false;
			},
			error: function() {
				Msger.closeClock();
			}
		}
		Msger.clockMsg('正在导出,请勿刷新...', 10);
		console.info(ajax);
		bbk.ajax(ajax);
	},
	clearPrice: function(i) {
		if (i == 1) {
			$('#export-batch-fixed-price').val('');
		} else {
			$('#export-batch-percent-price').val('');
		}
	},
	exportBatch: function() {
		Searcher.searcher.exportPage = '';
		Searcher.searcher.fixedPrice = '';
		Searcher.searcher.percentPrice = '';
		// let priceVal=(Searcher.searcher.page == Cons.PAGE.INDEX)?'value="500"':'';
		let priceUpHtml = '<div class="export-batch-label left">价格上调：</div>' +
			'<div class="export-batch-price-box left">' +
			'<input onclick="DataPartner.clearPrice(2)"  id="export-batch-fixed-price" class="bbk-input export-batch-price-input"  />&ensp;元&ensp;&ensp;&ensp;or&ensp;&ensp;&ensp;' +
			'<input onclick="DataPartner.clearPrice(1)" id="export-batch-percent-price" class="bbk-input export-batch-price-input" placeholder="1-100" />&ensp;%</div>' +
			'</div>';
		let content =
			'<div class="export-batch-box">' +
			'<div class="export-batch-line export-batch-first-line line">' +
			'<div class="export-batch-label left">导出范围：</div>' +
			'<div id="export-batch-size-box" class="left"><span class="export-batch-label">正在查询...<span></div>' +
			'</div>' +
			'<div class="export-batch-line line" style="margin-top:10px">' +
			priceUpHtml +
			'</div>' +
			'<div id="export-more-box"></div>';
		if (Searcher.searcher.page == Cons.PAGE.INDEX) {
			content += '<div style="text-align:center;font-size:14px;color:orange;">说明:「全网」商标至少加价500元</div>';
		}
		var layer = layui.layer;

		layer.open({
			title: '批量导出（筛选条件不同,导出的商标也不同）:',
			type: 1,
			resize: false,
			content: content,
			btn: ['批量导出(VIP)', '取消'],
			btn1: function() {
				let searcher = Searcher.searcher;
				if (bbk.isEmpty(searcher.exportPage)) {
					Msger.info('请选择「导出范围」');
					return false;
				}
				if (Searcher.searcher.noNames.indexOf('不含价格') == -1) {
					let fixedPrice = bbk.getVal('export-batch-fixed-price');
					let percentPrice = bbk.getVal('export-batch-percent-price');
					//如果是全网页面
					if (Searcher.searcher.page == Cons.PAGE.INDEX) {
						if (bbk.isEmpty(fixedPrice) && bbk.isEmpty(percentPrice)) {
							Msger.info('「全网」页面导出时，「价格上调」不能为空');
							return;
						}
						if (!bbk.isEmpty(fixedPrice)) {
							if (fixedPrice < 500) {
								Msger.info('「全网」页面导出时，加价不能低于500!');
								return;
							}
						}

					}
					if (!bbk.isEmpty(fixedPrice)) {
						if (!Reg.isNum(fixedPrice)) {
							Msger.info('价格只能是数字');
							return;
						}

						searcher.fixedPrice = fixedPrice;
					}
					if (!bbk.isEmpty(percentPrice)) {
						if (!Reg.isNum(percentPrice)) {
							Msger.info('价格只能是数字');
							return;
						}
						searcher.percentPrice = percentPrice / 100;
					}
				}

				let ajax = {
					url: '/export-batch',
					data: searcher,
					success: function(res) {
						if (!bbk.isEmpty(res.data)) {
							// location.href = res.data;
							bbk.down(res.data);
							Msger.info('导出成功');
						}
						Msger.closeClock();
						return false;
					},
					error: function(res) {
						Msger.closeClock();
						if (res.code == Cons.ERROR_CODE.NOT_LOGIN) {
							Login.login(false, function() {
								let ajax2 = {
									url: '/export-batch',
									data: Searcher.searcher,
									success: function(res) {
										if (!bbk.isEmpty(res
											.data)) {
											// location.href = res.data;
											bbk.down(res.data);
										}
										Msger.closeClock();
										Msger.info("导出成功");
										return false;
									},
									error: function() {
										Msger.closeClock();
									}
								}
								Msger.clockMsg('正在导出,请勿刷新...', 60);
								bbk.ajax(ajax2);
							});
							return false;
						}
					}
				}
				bbk.ajax(ajax);
				layui.layer.closeAll();
				Msger.clockMsg('正在导出,请勿刷新页面...', 60);
			}
		});
		let acBtn = {
			id: 'export-more-box',
			names: ['不含价格', '不含图样'],
			click: function(name, names) {
				Searcher.searcher.noNames = names;
			}
		}
		Searcher.searcher.noNames = [];
		AcBtn.render(acBtn);
		let ajax = {
			url: '/search-total',
			data: Searcher.searcher,
			success: function(res) {
				let names = [];
				let total = 500;
				if (res.data == 0) {
					$('#export-batch-size-box').html(
						'<span class="export-batch-label">没有查询到任何结果,请更换搜索条件「' + Searcher
							.searcher
							.text + '」</span>');
					return;
				}
				while (total < res.data && total < 3000) {
					names.push((total - 499) + '-' + total);
					total += 500;
				}
				if (res.data <= 3000) {
					names.push((total - 499) + '-' + res.data);
				} else {
					names.push((total - 499) + '-' + total);
				}
				Searcher.searcher.exportPage = 1;
				let acBtn = {
					names: names,
					default: [names[0]],
					id: 'export-batch-size-box',
					isSingle: true,
					click: function(name) {
						if (bbk.isEmpty(name)) {
							Searcher.searcher.exportPage = '';
						} else {
							let arr = name.split('-');
							Searcher.searcher.exportPage = (arr[0] - 1) / 500 + 1;
						}
					}
				}
				AcBtn.render(acBtn);
			},
			error: function(res) {
				if (res.code == Cons.ERROR_CODE.NOT_LOGIN) {
					Login.login(false, function() {
						bbk.reload(1.5);
					})
					return false;
				}

			}
		}
		bbk.ajax(ajax);
	},
	//收藏
	save: function() {
		let mySaver = localStorage.INDEX_SAVER_BRANDER;
		mySaver = bbk.isEmpty(mySaver) ? [] : JSON.parse(mySaver);
		for (let i = 0; i < ChooseItemer.ids.length; i++) {
			mySaver.add(ChooseItemer.ids[i]);
		}
		localStorage.INDEX_SAVER_BRANDER = JSON.stringify(mySaver);
		Msger.info('收藏成功');
	},
	//取消收藏
	delete: function(isAll) {
		if (isAll) {
			Msger.isSure('确定清空收藏?', function() {
				localStorage.INDEX_SAVER_BRANDER = '';
				Searcher.items.removeAll();
				Msger.info('已清空');
			});
		} else {
			Msger.isSure('确定将勾选的<span class="big-blue">' + ChooseItemer.ids.length +
				'</span>个商标取消收藏?',
				function() {
					let mySaver = localStorage.INDEX_SAVER_BRANDER;
					mySaver = bbk.isEmpty(mySaver) ? [] : JSON.parse(mySaver);
					for (let i = 0; i < ChooseItemer.ids.length; i++) {
						mySaver.remove(ChooseItemer.ids[i]);
						let index = Searcher.getItemById(ChooseItemer.ids[i]);
						Searcher.items.splice(index, 1);
					}
					localStorage.INDEX_SAVER_BRANDER = JSON.stringify(mySaver);
					Msger.info('已取消');
				});
		}

	},
}
BrotherType = {
	type: '',
	show: function() {
		layer.open({
			title: '同名标声明:',
			type: 1,
			resize: false,
			content: '<div  id="layer-brother-type-box" class="flex-center"></div><div onclick="BrotherType.post()" class="layui-btn layui-btn-sm layui-btn-normal layui-brother-type-btn">提交</div>',
			area: ['500px', '200px'],
		});
		BrotherType.type = '';
		let acBtn = {
			id: 'layer-brother-type-box',
			names: [Cons.BROTHER_TYPE.getByNum(1), Cons.BROTHER_TYPE.getByNum(2), Cons.BROTHER_TYPE
				.getByNum(3)
			],
			click: function(name, names) {
				BrotherType.type = name;
			},
			isSingle: true
		}
		AcBtn.render(acBtn);
	},
}

Itemer = {
	onmouseenter: function(obj) {
		let e = $(obj).find('i').css('display', 'inline-block');
		let item = Searcher.getItemById(obj.id);
		if (item.errorCode == 0 && bbk.isEmpty(item.errorMsg)) {
			return;
		}
		//有异常的时候,还是要显示
		let client = obj.getBoundingClientRect();
		let left = client.left < 486 ? 228 : -304;
		$(obj).find('.item-more-info-box').css('display', 'block').css('left', left);
		if (left > 0) {
			$(obj).find('.item-more-info-box').css('box-shadow', '3px 3px 2px #eee');
		} else {
			$(obj).find('.item-more-info-box').css('box-shadow', '-3px 3px 2px #eee');
		}
	},
	onmouseleave: function(obj) {
		let e = $(obj).find('i').css('display', 'none');
		$(obj).find('.item-more-info-box').css('display', 'none');
	}
}
Controller = {
	openPc: function() {
		localStorage.INDEX_NOT_AUTO_OPEN_MOBILE_TIME = bbk.getDate();
		window.location.href = '/';
	}
}
window.onload = function() {
	Searcher.init();
}
